def append(head=None,tail=None,result=None):
    h = head is not None
    t = tail is not None
    r = result is not None
    
    if h and t and not r:
        result = head+tail
    
    elif h and r and not t:
        assert result[:len(head)] == head
        tail = result[len(head):]
    
    elif t and r and not h:
        if not tail:
            head = result
        else:
            assert result[-len(tail):] == tail
            head = result[:-len(tail)]
    
    elif h and t and r:
        assert head+tail == result
